import { skipComments } from "./skipComments";

const content = `export default {
  test: "你好,世界",
  "views.ShowCase.index.zhengzaijiazai": "正在加载...",
  "views.ShowCase.index.meiyougengduola": "没有更多啦~",
  "common.hot": "热",
  "common.xiaoshi": "小时前",

  // 购物车/进货单
  commonadd: "加入进货单",
  "common.cart.2C.add": "加入购物车",
  "common.cart.2B": "进货单",
  "common.cart.2C": "购物车",

  "common.currency.points": "积分",//*,***/
  //asdsads/****
  /* */
};
`;
const sys = ["`", '"', "'"];
export const isComma = (content: string) => {
  //获取国际化对象里面的key,value
  let text = content.slice(content.indexOf("{") + 1, content.lastIndexOf("}"));
  //过滤掉注释
  text = skipComments(text) || "";
  let strSyIndex = 0;
  let commaIndex = text.lastIndexOf(",");
  sys.forEach((s) => {
    let index = text.lastIndexOf(s);
    if (index > strSyIndex) {
      strSyIndex = index;
    }
  });
  return strSyIndex > commaIndex;
};
export const insertStr = (content: string, str: string) => {
  const lastIndex = content.lastIndexOf("}");
  return content.slice(0, lastIndex) + str + content.slice(lastIndex);
};
